home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_pow_drepeater_m.cog < prev    next >
Text File  |  1998-02-25  |  4KB  |  141 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # POW_REPEATER.COG
  4. #
  5. # POWERUP Script - Dropped Repeater Gun
  6. #
  7. # [YB & CYW & CR]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10.  
  11.  
  12. symbols
  13.  
  14. thing       powerup                          local
  15. thing       player                           local
  16. int         bin=6                            local
  17. int         ammobin=12                       local
  18. sound       pickupsnd=powerpu1.wav           local
  19. sound       respawnsnd=Activate01.wav        local
  20. flex        amount                           local
  21.  
  22. int         bin_contents=0                   local
  23. int         autopickup=0                     local
  24. int         autoselect_weapon=-1             local
  25.  
  26. message     touched
  27. message     taken
  28. message     respawn
  29.  
  30. end
  31.  
  32. # ========================================================================================
  33.  
  34. code
  35.  
  36. touched:
  37.    player = GetSourceRef();
  38.  
  39.    if (GetThingType(player) == 10)  // Can only be taken by players.
  40.    {
  41.       if(IsMulti() || (GetInv(player, bin) == 0) || (GetInv(player, ammobin) < GetInvMax(player, ammobin)))
  42.       {
  43.          TakeItem(GetSenderRef(), -1);
  44.          call taken;
  45.       }
  46.    }
  47.  
  48.    Return;
  49.  
  50. # ........................................................................................
  51.  
  52. taken:
  53.    player = GetSourceRef();
  54.    powerup = GetSenderRef();
  55.  
  56.    // Do effects.
  57.    PlaySoundLocal(pickupsnd, 1, 0, 0);
  58.    AddDynamicTint(player, 0.0, 0.0, 0.2);
  59.  
  60.    if(GetInv(player, bin) == 0)
  61.    {
  62.       // Pickup gun and ammo.
  63.       // Print("Repeater Gun");
  64.       jkPrintUNIString(player, bin);
  65.  
  66.       ChangeInv(player, bin, 1.0);
  67.  
  68.       // store the old bin contents
  69.       bin_contents = GetInv(player, ammobin);
  70.       ChangeInv(player, ammobin, 12.0);
  71.  
  72.       // Check for Auto Pickup
  73.       autopickup = GetAutoPickup();
  74.       if(autopickup & 1)
  75.       {
  76.          if(!((autopickup & 4) && (GetWeaponPriority(player, GetWeaponBin(GetCurWeapon(player)), 0) >= GetWeaponPriority(player, bin, 0))))
  77.          {
  78.             if(!((autopickup & 8) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  79.             {
  80.                SelectWeapon(player, bin);
  81.                Return;
  82.             }
  83.          }
  84.       }
  85.  
  86.       // Check for Auto Reload
  87.       if(GetAutoReload() & 1)
  88.       {
  89.          if(!bin_contents)
  90.          {
  91.             if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  92.             {
  93.                // Try to autoselect and see if the best weapon is a power cell weapon
  94.                autoselect_weapon = AutoSelectWeapon(player, 2);
  95.                if((autoselect_weapon == 6) || (autoselect_weapon == 9) || (autoselect_weapon == 15))
  96.                   SelectWeapon(player, autoselect_weapon);
  97.             }
  98.          }
  99.       }
  100.    }
  101.    else
  102.    if(GetInv(player, ammobin) < GetInvMax(player, ammobin))
  103.    {
  104.       // Pickup ammo only.
  105.       // Print("Power Cells");
  106.       jkPrintUNIString(player, ammobin);
  107.  
  108.       // store the old bin contents
  109.       bin_contents = GetInv(player, ammobin);
  110.  
  111.       ChangeInv(player, ammobin, 12.0);
  112.  
  113.       // Check for Auto Reload
  114.       if(GetAutoReload() & 1)
  115.       {
  116.          if(!bin_contents)
  117.          {
  118.             if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  119.             {
  120.                // Try to autoselect and see if the best weapon is a power cell weapon
  121.                autoselect_weapon = AutoSelectWeapon(player, 2);
  122.                if((autoselect_weapon == 6) || (autoselect_weapon == 9) || (autoselect_weapon == 15))
  123.                   SelectWeapon(player, autoselect_weapon);
  124.             }
  125.          }
  126.       }
  127.    }
  128.  
  129.    Return;
  130.  
  131. # ........................................................................................
  132.  
  133. respawn:
  134.    PlaySoundThingLocal(respawnsnd, GetSenderRef(), 0.6, 5.0, 10.0, 0);
  135.  
  136.    Return;
  137.  
  138. end
  139.  
  140.  
  141.